package net.pulseproject.router.config.instantiator.builder;

import net.pulseproject.router.config.instantiator.builder.validator.FieldValidator;
import net.pulseproject.router.config.instantiator.builder.validator.SkeletonFieldValidator;
import net.pulseproject.router.modules.useable.SimpleMergerModule;


public class SimpleMergerModuleBuilder extends BiDirectionalModuleBuilder<SimpleMergerModule> {
	
	private Integer fanIn = null;

	private final FieldValidator validator = new SkeletonFieldValidator() {
		@SuppressWarnings("synthetic-access")
		@Override
		protected void validateFields() {
			if(SimpleMergerModuleBuilder.this.fanIn == null) {
				throw new RuntimeException("fanIn not yet set");
			}
		}
	};

	public SimpleMergerModuleBuilder() {
		this.addValidator(this.validator);
	}

	public final void setFanIn(final Integer fanIn) {
		this.fanIn = fanIn;
	}
	
	@Override
	protected final SimpleMergerModule buildModule() {
		return new SimpleMergerModule(this.getId(), this.getOutgoingModules(), this.fanIn.intValue());
	}
	
}
